#include "ms_voxelimage.h"
#include "ms_sphere.h"
#include "ms_cylinder.h"
#include "ms_misc.h"
#include "unistd.h"
using namespace std;

int main(int argc, char ** argv)
{
// 	double Q[3][3], N[]={0.,1.,1.}, QQt[3][3], y, L = VectorNorm(N);
// 	for(int i=0;i<3;i++) N[i] /= L;
// 	GetRotationMatrix(Q, N );
// 	for(int i=0;i<3;i++)
// 	{
// 		for(int j=0;j<3;j++)
// 		{
// 			QQt[i][j] = 0.;
// 			for(int k=0;k<3;k++)
// 				QQt[i][j] += Q[i][k]*Q[j][k];
// 			printf("   %10.6lf", Q[i][j]);
// 		}
// 		printf("\n");
// 	}
// 	return 0;
	sphere S( (double[]){ 0., 0., 0.}, 0.5 );
	VoxelImage vx_img( 1, 200, '\0' );
	
	S.DrawVoxelImage(vx_img, '*'); /* '\123' --> 'Farbe' 123 */
//	vx_img.DrawCircleZ( (double[]){0.5,0.5,0.}, 0.25, 'X' );
	
	sphere SS( (double[]){ 0.3, 0.3, -0.2}, 0.3);
	SS.DrawVoxelImage(vx_img, 'Z');

	sphere SSS( (double[]){ -0.2, 0.3, 0.1}, 0.3);
	SSS.DrawVoxelImage(vx_img, ' ');

	sphere SSSS( (double[]){ 0.1, 0.1, 0.1}, 0.2);
	SSSS.DrawVoxelImage(vx_img, '*');

// 	vx_img.DrawLine( (int[]){1,1,1}, (int[]){1,1,49}, '*');
// 	vx_img.DrawLine( (int[]){1,1,1}, (int[]){49,1,1}, '*');
// 	vx_img.DrawLine( (int[]){1,1,1}, (int[]){1,49,1}, '*');
// 	vx_img.DrawLine( (int[]){1,1,1}, (int[]){1,1,49}, '*');
// 	printf("h=%lf\n", vx_img.h);
// 	vx_img.DrawLine( (double[]){-0.5,-0.5,-0.5}, (double[]){0.5,0.5,0.5}, '*');
// 	vx_img.DrawLine( (double[]){-0.5,-0.5,-0.5}, (double[]){-0.5,-0.5,0.5}, '*');
// 	vx_img.DrawLine( (double[]){-0.5,-0.5,-0.5}, (double[]){0.5,-0.5,-0.5}, '*');
// 	vx_img.DrawLine( (double[]){-0.5,-0.5,-0.5}, (double[]){-0.5,0.5,-0.5}, '*');
	vx_img.WriteVTKFile("spheres.vtk");
	return 0;
// 	vx_img.DrawLine( (int[]){0,0,0}, (int[]){49,49,49}, '*');
/*	for(int ix=10;ix<=10; ix++)
	{
// 		vx_img.DrawLine( (int[]){ix,0,0}, (int[]){ix,15,30}, '*');
		vx_img.DrawLine( (int[]){ix,1,0}, (int[]){ix,30,30}, '*');
	}	*/
// 	
	int iz = (vx_img.Nz-1)/2 + 5;
	
	for(iz = 0; iz < vx_img.Nz; iz++)
	{
		for(int iy=0; iy<vx_img.Ny; iy++) {
			for(int ix=0; ix<vx_img.Nx; ix++)
				printf("%c",vx_img.data[ix][iy][iz]);
			printf("\n");
		}
		printf("SLICE %3d\n",iz+1);
		usleep(50000);
	}
	
	return 0;
}
